package com.flipdf2.serialize.ppml.element;

import org.jdom.Element;
import org.jdom.Namespace;

import com.flipdf2.serialize.ppml.PPMLException;

public class PPMLConformance {
	public static final String NAME = "CONFORMANCE";
	
	/**The subset value should come from PPMLConstant*/
	private String subset;
	private String level;

	public Element toXML(Namespace defaultNamespace) {
		Element root = null;
		if (defaultNamespace != null) {
			root = new Element(NAME, defaultNamespace);
		} else {
			root = new Element(NAME);	
		}
		
		if (subset != null && subset.length() > 0)
			root.setAttribute("Subset", subset);
		if (level != null && level.length() > 0)
			root.setAttribute("Level", level);
		
		return root;
	}
	
	public void check() throws PPMLException {
		if (subset == null) {
			throw PPMLException.getInstance(PPMLException.REQUIRED_ATTRIBUTE_LOST, "Subset");
		}
	}
	
	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getSubset() {
		return subset;
	}

	public void setSubset(String subset) {
		this.subset = subset;
	}
}
